%Image Processing Assignment - 1
%Name: - Kirtish Dhande
%Class: - B.E. - C
%Roll no: - 54
% This is the program to flip vertically up an image.
%Date of assignment - 12/01/2016

%Variables declared -
% A - used to access original image.
% B - used to work on resultant/final image.
% A1 - will be used for calculations purpose.

clc;
clear all;
close all;

%This stores the pixel values of images in A.
A = imread('cameraman.tif');

%Displays the image in A.
imshow(A)
title('Original Image');

%To flip the image we need the size of the image first.
[m,n]= size(A);

%Convert and store values as double in A1.
A1 = double(A);

%Traverse from top to bottom in row,
%Traverse from right to left in column,
%and store the values in B.
for i=1:m
    for j=1:n
        B(i,j)=A1(i,n-j+1);
    end
end

%Convert the double values back, store in B and display the image.
figure, imshow(uint8(B));
title('New Image');